package com.shangyueshang.request;

import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.Data;

import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
import java.math.BigDecimal;
import java.time.LocalDate;
import java.time.YearMonth;

/**
 * @author: JokeyZheng
 * @email: zhengjingfeng@ruqimobility.com
 * @created: 2022/1/18 17:26
 * @version: v1.0.0
 */
@Data
public class AccountingDTO {

    /**
     * 店铺名称
     */
    @NotBlank(message = "店铺名称必填")
    private String shop;

    /**
     * 统计月份
     */
    @NotNull(message = "统计月份必填")
    @JsonFormat(pattern = "yyyy-MM")
    private YearMonth tradeMonth;

    /**
     * 汇率
     */
    @NotNull(message = "汇率必填")
    private BigDecimal exchangeRate;

    /**
     * 获取月份的第1天
     *
     * @return
     */
    public LocalDate tradeMonthStartDate() {
        return this.tradeMonth.atDay(1);
    }

    /**
     * 获取月份的最后1天
     *
     * @return
     */
    public LocalDate tradeMonthEndDate() {
        return this.tradeMonth.atEndOfMonth();
    }

}
